<extend name="Public/base"/>
<block name="body">
    <div class="main-title">
        <h2>扩展自动升级 - 完成，同步版本号和Token</h2>
    </div>
    <div class="with-padding" style="width:700px;">
        <h3 style="padding-top: 0;margin-top: 0">
            当前升级的扩展
        </h3>
        <ul class="module-list">
            <volist name="modules" id="vo">
                <li class="clearfix" style="margin-bottom: 0">
                    <div class="cover-wrapper">
                        <empty name="vo.version_info.goods.cover_url">
                            <div class="cover-icon">
                                <i class="icon-{$vo.icon}"></i>
                            </div>
                            <else/>
                            <img class="cover"
                                 src="__CLOUD__/{$vo.version_info.goods.cover_url}"/>
                        </empty>


                    </div>
                    <div class="content-wrapper">
                        <div class="title">
                            <a href="{:U('Admin/Module/edit', array('name' => $vo['name']))}">{$vo.alias} <span class="text-muted">{$vo.name}</span></a>

                            <div class="pull-right"><span class="label label-info">{$vo.version_info.title}</span>
                                <empty name="vo.update_list">
                                    <else/>
                                    <a style="text-decoration: none"
                                            ><span class=" label label-success ">最新版{$vo.update_list.0.title}</span></a>
                                </empty>
                            </div>
                        </div>
                        <div>
                            <p class="text-muted text-ellipsis">{$vo.summary}</p>
                        </div>
                        <div>开发者： <a style="color: #666">{$vo.developer}</a></div>
                        <div class="clearfix bottom-btns">
                            <div class="pull-left">
                                <a class="btn btn-default"
                                   href="{:U('Module/edit', array('name' => $vo['name']))}">编辑</a>
                            </div>
                            <div class="pull-right">
                                <empty name="vo.token">
                                    <span class="label label-circle label-danger">本地模块</span>
                                    <else/>
                                    <a target="_blank"
                                       href="{:appstoreU('Appstore/Index/goodsDetail',array('token'=>$vo['token']))}"
                                       class="btn btn-info">去云市场查看</a>
                                </empty>
                            </div>
                        </div>
                    </div>
                </li>
            </volist>
        </ul>
        <p><strong class="text-success">1.下载更新包，获取更新文件列表 -》 2.本地文件对比 -》 3.代码升级 -》 4.数据库升级 -》升级完成</strong></p>
        <h4>
            恭喜，升级成功，目前版本为 {$modules.0.version_info.title}
        </h4>

        <p>如果发现升级之后出现问题，请找回备份文件，同时还原备份的数据库。</p>


        <p>
            {$path}/backup

        </p>

        <div class="row">
            <div class="col-xs-7">
                <a id="compare_btn" class="btn btn-success btn-block"
                  href="{:U('updateGoods',array('token'=>$token))}">返回自动升级首页</a>
            </div>

        </div>

    </div>


    <script>
        function updateDB(obj) {
            if (!confirm('确定导入？强烈建议在导入之前进行数据库备份。')) {
                return false;
            } else {
                toast.showLoading();
                $(obj).attr('disabled', 'disabled');
                $(obj).text('正在升级数据库，请耐心等待……');
                $.post('__SELF__', function (msg) {
                    if (msg.status) {
                        $(obj).removeAttr('disabled');
                        toast.hideLoading();
                        toast.success('数据库升级成功。');
                        $(obj).text('升级数据库成功，进入下一步');
                        $(obj).attr('href',"{:U('finish')}");

                    } else {
                        toast.error('升级失败。请检测后再试。')
                    }
                })
            }
        }
        function writeFile($data) {
            $('#file').append('<div><i class="icon-file"></i> ' + $data + '</div>');
        }
        function writeMessage($data) {
            $('#message').append($data);
        }
        function replaceMessage($data) {
            $('#message').children().last().remove();
            $('#message').children().last().remove();
            $('#message').append($data);
        }
        var progress = {
            'show': function () {
                $('#progress').parent().show();
            },
            'setValue': function ($value) {
                $('#progress').css('width', $value);
            },
            'hide': function () {
                $('#progress').parent().hide();
            }
        };
        function enable() {
            $('#compare_btn').removeAttr('disabled', '');
        }
    </script>
</block>